﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ERPStore.Extensions
{
	public static class SettingsExtensions
	{
		public static Models.Price GetDefaultFreeOfShippingPrice(this Settings.WebSiteSettings settings)
		{
			var ddc = settings.GetDefaultDeliveryCountry();
			return new Models.Price(ddc.MinimalFreeOfCarriageAmount, ddc.TaxRate / 100d);
		}

		public static Models.DeliveryCountry GetDefaultDeliveryCountry(this Settings.WebSiteSettings settings)
		{
			var deliveryCountry = settings.Shipping.DeliveryCountryList.Single(i => i.CountryId == settings.CountryId);
			return deliveryCountry;
		}

		public static decimal GetDefaultMinimalOrderAmount(this Settings.WebSiteSettings settings)
		{
			return settings.GetDefaultDeliveryCountry().MinimalOrderAmount;
		}

		public static double GetDefaultShippingTaxRate(this Settings.WebSiteSettings settings)
		{
			return settings.GetDefaultDeliveryCountry().TaxRate;
		}

	}
}
